home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / GMSMTH01.ZIP / INCLUDE / SPRBANK.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-08  |  6.2 KB  |  190 lines

  1. /*
  2.  
  3.     sprbank.h
  4.  
  5.     Written Bruce Miller
  6.  
  7.     Internet: alexad3@icebox.iceonline.com
  8.     Copyright 1995, April 13 by Bruce Miller, ALL rights reserved
  9.  
  10.     Created - 1995/4/13
  11.  
  12.     History:
  13.         New file
  14.  
  15.  
  16.     Modified 21Apr95 by Bruce Miller:
  17.  
  18.      * Moved init_sprite_bank() into sprbank.c from sprite.c, removed
  19.        header from sprite.h, added to sprbank.h
  20.  
  21.      * Added global spriteBanks array and MAX_SPRITE_BANKS constant for
  22.        purposes of de-initing memory used by sprite structures.
  23.  
  24. */
  25.  
  26. #ifndef DEF_SPRBANK
  27. #define DEF_SPRBANK
  28.  
  29.  
  30. // filename: SprBank.h           ** see end of file for documenation **
  31.  
  32. //------------ Constants ---------------
  33. #define MAX_SPRITE_BANKS 32
  34. enum collisionMessages  {  CHECK_ONLY = 1   };
  35.  
  36. //------------ Global Data Declarations --------------------
  37. extern sprite_bank_t far * far spriteBanks[];
  38. extern short numSpriteBanks;
  39.  
  40.  
  41. //-------------- Function prototypes -----------------------
  42. void init_sprites( void );
  43. void deinit_sprites( void );
  44. sprite_bank_t far *init_sprite_bank(short max_sprites);
  45. void deinit_sprite_bank( sprite_bank_t far *bank );
  46.  
  47. sprite_bank_t far *setup_spritebank(char *spriteFileName, short numInstances,
  48.                 short id,  short clip_left, short clip_right,
  49.                            short clip_top, short clip_bottom,
  50.                 short x_min, short x_max, short y_min, short y_max,
  51.                 short erase, short max_instance);
  52.  
  53. void move_limit_spritebank(sprite_bank_t far *bank_ptr);
  54. void move_limit_all_banks(void);
  55.  
  56. void draw_spritebank(sprite_bank_t far *bank_ptr);
  57. void draw_spritebank_offs( sprite_bank_t far *bank_ptr, short x_offs,
  58.                            short y_offs );
  59.  
  60. void draw_all_banks(void);
  61. void offset_draw_all_banks(short xOffs, short yOffs);
  62.  
  63. sprite_t far *start_next_in_spritebank(sprite_bank_t far *bank,
  64.               short changeMode, short moveMode, short x, short y, short dx,
  65.               short dy);
  66.  
  67. sprite_t far *detect_collisions(short message, sprite_bank_t far *refBank,
  68.                                           sprite_bank_t far *testBank);
  69.  
  70. /* D
  71.  DOCUMENATION:
  72.  
  73. ------------------------------------------------------------------------------
  74.  
  75.  init_sprite_bank() - allocates memory, intializes a sprite bank.
  76.  
  77.  Syntax:
  78.     sprite_bank_t far *init_bank_sprite(short max_sprites);
  79.  
  80.  Inputs:
  81.  
  82.  
  83.  Returns:
  84.  
  85.  
  86.  Notes:
  87.  
  88.  
  89. ------------------------------------------------------------------------------
  90. ------------------------------------------------------------------------------
  91.  
  92.  setupSpriteBank(): reads a sprite file from disk, and intializes it as a
  93.                                         sprite bank.
  94.  Syntax:
  95.     sprite_bank_t far *setupSpriteBank( char *spriteFileName, short numInstances,
  96.                          short id, short x_min, short x_max, short y_min, short y_max );
  97.  
  98.  Inputs:
  99.     char *spriteFileName - near pointer to the sprite file name
  100.     short numInstances   - number of instances of the sprite you wish to create
  101.     short id             - id number to identify sprite instances
  102.     short x_min, short x_max, short y_min, short y_max
  103.                                              - bounding rectangle for movements
  104.  Returns:
  105.     sprite_bank_t far *  - far pointer to the sprite bank
  106.                                              - or NULL if unsuccessful
  107.  Notes:
  108.     - Allocates memory using gmalloc
  109.     - Allocates enough storage for MAX_SPRITES_PER_BANK instances
  110.     - initializes 'numInstances' sprites using add_sprite_instance()
  111.     - File must be standard sprite file
  112.  
  113. ------------------------------------------------------------------------------
  114.  
  115.  moveDrawAllSprites(): moves sprites, changes bitmaps, limits sprites,
  116.                                              adds erase rects, draws bitmaps for a list of
  117.                                              sprite banks.
  118.  
  119.  Syntax:
  120.     void moveDrawAllSprites( sprite_bank_t far * far *spriteBanks,
  121.                                                      short numBanks );
  122.  
  123.  Inputs:
  124.      sprite_bank_t far * far *spriteBanks - list of far pointers to sprite banks
  125.      short numBanks                       - number of sprite banks in list
  126.  
  127.  Returns:
  128.      none
  129.  
  130. ------------------------------------------------------------------------------
  131.  
  132.  startNextSpriteInBank() - start next available (not already active) sprite
  133.                                                      in specified bank. Conveniant way to start each
  134.                                                      sprite, all houskeeping done automatically.
  135.  
  136.  Syntax:
  137.      sprite_t far *startNextSpriteInBank( sprite_bank_t far *bank,
  138.         short changeMode, short moveMode, short x, short y, short dx, short dy );
  139.  
  140.  Inputs:
  141.      sprite_bank_t far *bank - far pointer to sprite bank
  142.      short changeMode        - type of bitmap frame changes required
  143.                                                          -1 = default from sprite header
  144.      short moveMode          - type of bitmap movement limiting required
  145.                                                          -1 = default from sprite header
  146.      short x, short y        - initial x, y position
  147.      short dx, short dy      - delta x, delta y for the movement
  148.  
  149.  Returns:
  150.      sprite_t far *          - far pointer to the sprite instance
  151.                                                          or NULL if no sprites available
  152.  
  153.  Notes:
  154.  
  155. ------------------------------------------------------------------------------
  156.  
  157. ------------------------------------------------------------------------------
  158.  
  159.  detectCollisions() - detects collisions from sprites in the ref bank, with
  160.                                             sprites in test bank.  Returns when first collision
  161.                                             detected.
  162.  Syntax:
  163.      sprite_t far *detectCollisions( short message, sprite_bank_t far *refBank,
  164.                                                                      sprite_bank_t far *testBank );
  165.  
  166.  Inputs:
  167.      short message               - unless set to CHECK_ONLY, test sprite is set to
  168.                                                                     to inactive, test and ref sprite collision
  169.                                                                     flags are set to 1.
  170.      sprite_bank_t far *refBank  - bank of reference sprites
  171.      sprite_bank_t far *testBank - bank of test sprites
  172.  
  173.  Returns:
  174.      sprite_t far *              - pointer to the test sprite which collided
  175.                                                                  with the ref sprite (both closest to start
  176.                                                                  of list in bank).
  177.  
  178.  Notes:
  179.      - normally use with message set to 0, test sprite is set to inactive,
  180.          next time it is called the now-inactive sprite will be skipped, so will
  181.          not detect the same collision over and over.
  182.  
  183. ------------------------------------------------------------------------------
  184.  
  185.  
  186. */
  187.  
  188. /* ------------------------------ EOF -------------------------------- */
  189. #endif
  190.